// JavaScript Document
//start
var lib=(function(){
var PLAYER=function(){}
	PLAYER.fn             = PLAYER.prototype;
 	PLAYER.fn.constructor = PLAYER;		
	window.TOOLS          = PLAYER;
			
})()
TOOLS.getCoordinates = function( e , id ){
    x = e.clientX;
    y = e.clientY;
    document.getElementById(id).innerHTML="Coordinates: (" + x + "," + y + ")";
}
TOOLS.appendJs=function(srcJs,end){	
    var head=document.getElementsByTagName('head')[0];
    var script=document.createElement("script"); 
    script.setAttribute("type","text/javascript"); 
    script.setAttribute("src",srcJs);// 在这里引入了a.js 
	if(!end){
        head.insertBefore(script,head.childNodes[0]); 
	}else{
	    head.appendChild(script);	
	}
}
TOOLS.require=function(srcJs){
    document.write('<script src="'+srcJs+'" type="text/javascript"></script>')	
}

//true 的触发顺序总是在 false 之前；
//如果多个均为 true，则外层的触发先于内层；
//如果多个均为 false，则内层的触发先于外层。

TOOLS.ready=function(callback){
	if(document.addEventListener){
		document.addEventListener(
		    "DOMContentLoaded",
		    function(){
			   // document.removeEventListener("DOMContentLoaded",arguments.callee,false);
			    callback();
				console.log('removeEventListener');
				console.log(arguments.callee)
				
		    },
			false
		);
	}else if(document.attachEvent){
		document.attachEvent(
		    "onreadystatechange",
		    function(){
			    if ( document.readyState === "complete" ) {
				    document.detachEvent( "onreadystatechange", arguments.callee );
				    callback();
					console.log('detachEvent');
					//alert(arguments.callee)
			    }
		    }
		)
	 }
}
TOOLS.mkDiv=function(id,cssText,innerHTML,bl){
   var innerHTML =innerHTML || "";
   var body=document.getElementsByTagName('body')[0];
   var div = document.createElement("div");
   
   if(! bl ){
      div.id=id; 
   }
   div.className=id;
   div.innerHTML=innerHTML;
   div.style.cssText=cssText;
   body.insertBefore(div,body.childNodes[0]);	
}
//end
//javascript
 

TOOLS.removeChild=function(father,childs  ){	
    if(typeof childs=="undefined"){
		childs=father;
		for(i=0;i<childs.length;i++){
		    childs[i].parentNode.removeChild( childs[i] )	
		}
	   return;	
	}
    for(i=0;i<childs.length;i++){
		try{ 	
	    father.removeChild( childs[i] );
		}catch(e){
		     childs[i].parentNode.removeChild( childs[i] )	
		}
	}
}

 

